<?php

/**
 * 刮刮卡模块处理程序
 *
 * @url 
 */
defined('IN_IA') or exit('Access Denied');

class Laoyou_csyxModuleProcessor extends WeModuleProcessor {

    public function respond() {
        global $_W;
        $rid = $this->rule;
        $sql = "SELECT * FROM " . tablename('laoyou_csyx_reply') . " WHERE `rid`=:rid LIMIT 1";
        $row = pdo_fetch($sql, array(':rid' => $rid));
        $today = date('Ymd', time());
        $starttime = date('Ymd', $row['starttime']);
        $endtime = date('Ymd', $row['endtime']);
        
        if ($row == false) {
            return $this->respText("活动已取消...");
        }
        if ($today < $starttime) {
            return $this->respText("活动尚未开始...");
        }
        if ($today > $endtime) {
            return $this->respText("活动已过期...");
        }
        
        if (!empty($row['r_title'])) {
            $title = $row['r_title'];
        } else {
            $title = ' ';
        }
        if (!empty($row['reply'])) {
            $description = $row['reply'];
        } else {
            $description = ' ';
        }
        if (!empty($row['img_url'])) {
            $picUrl = toimage($row['img_url']);
        } else {
            $picUrl = ' ';
        }
        $url = $this->createMobileUrl('index', array('id' => $rid));
        
        return $this->respNews(array(
                    'Title' => $title,
                    'Description' => $description,
                    'PicUrl' => $picUrl,
                    'Url' => $url
        ));
    }

}
